import React from "react";
import { Switch, Route, Redirect } from "react-router-dom";
// import Login from "./pages/Login/Login";
// import Register from "./pages/Register/Register"
// import Index from "./pages/Index/Index"
// import List from "./pages/List/List"
// import Detail from "./pages/Detail/Detail"
import { DotLoading } from "antd-mobile";
const Search = React.lazy(() => import("./pages/Search/Search"));
// import Search from "./pages/Search/Search"
const Detail = React.lazy(() => import("./pages/Detail/Detail"));
const List = React.lazy(() => import("./pages/List/List"));
const Register = React.lazy(() => import("./pages/Register/Register"));
const Index = React.lazy(() => import("./pages/Index/Index"));
const Login = React.lazy(() => import("./pages/Login/Login"));
const App = () => {
  return (
    <div className="app">
      <React.Suspense fallback={<DotLoading color={"red"} />}>
        {/* Switch 路由视图 */}
        <Switch>
          {/* Route 路由规则 */}
          <Route path="/login" component={Login}></Route>
          <Route path="/register" component={Register}></Route>
          <Route path="/index" component={Index}></Route>
          <Route path="/list" component={List}></Route>
          <Route path="/detail/:id" component={Detail}></Route>
          <Route path="/search" component={Search}></Route>

          {/* Redirect 重定向 */}
          <Redirect to="/login"></Redirect>
        </Switch>
      </React.Suspense>
    </div>
  );
};

export default App;
